<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>canvasL</title>
    <style>
        canvas{background-color:lightblue;}
    </style>
</head>
<body>
<canvas id="canvas" width="600px" height="600px">您的浏览器不支持</canvas>
<script>
    var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext('2d');

    ctx.beginPath();
    ctx.translate(0, 100);
    ctx.rotate(Math.PI / 3);
    ctx.scale(0.5);
    ctx.moveTo(100, 100);
    ctx.lineTo(300, 100);
    ctx.lineTo(300, 300);
    ctx.lineTo(100, 300);
    ctx.closePath();
    ctx.stroke();
    ctx.fillStyle = "#FFFF00";
    ctx.fill();

</script>
</body>
</html>